package github.sf.fw.tools.tree;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * example:
 * <pre>
 *     @AutoService(value = {Node.class, BaseTreeNode.class})
 * @Data
 * public class TTNode implements BaseTreeNode {
 *     private String id;
 *     private String name;
 *     private List<BaseTreeNode> children = new ArrayList<>();
 *
 *     @Override
 *     public void copyFrom(Node node) {
 *         if (TNode.class.isAssignableFrom(node.getClass())) {
 *             this.id = String.valueOf(((TNode) node).getNodeId());
 *             this.name = ((TNode) node).getName();
 *         }
 *     }
 *
 *     @Override
 *     public List<BaseTreeNode> getChildren() {
 *         return children;
 *     }
 *
 *     @Override
 *     public void setChildren(List<BaseTreeNode> baseTreeNodes) {
 *         this.children = baseTreeNodes;
 *     }
 *
 *     @Override
 *     public Object getNodeId() {
 *         return this.id;
 *     }
 * }
 * </pre>
 *
 * @see BaseNode
 */
public interface BaseTreeNode extends Node {

    Object obtainNodeId();

    void copyFrom(Node node);

    Object obtainParentId();

    List<BaseTreeNode> obtainChildren();

    void addChildren(BaseTreeNode baseTreeNode);

    default void addPath(String path) {

    }

    default void addPathList(Collection<String> paths) {

    }

    default List<String> obtainPath() {
        return new ArrayList<>();
    }

    /**
     * 给children排序，默认不排序
     */
    default void sortChildren() {

    }
}
